package com.fh.service.system.appuser;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.fh.dao.DaoSupport;
import com.fh.entity.Page;
import com.fh.entity.system.Account;
import com.fh.entity.system.Project;
import com.fh.entity.system.Unfundproject;
import com.fh.util.PageData;


@Service("appUserProjectService")
public class AppUserProjectService {

	@Resource(name = "daoSupport")
	private DaoSupport dao;
	
	//======================================================================================
	
	 
	/**查找用户项目
	 * 
	 * <p>Title: listPdPageUser</p>
	 * <p>Description: </p>
	 * @param page   根据用户id
	 * @return
	 * @throws Exception
	 */
	public List<PageData> listAllUserProject(Page page)throws Exception{
		return (List<PageData>) dao.findForList("UnfundrojectMapper.findUsersProject", page);
	}
	/**
	 * 
	 * <p>Title: findAllProject</p>
	 * <p>Description: </p>
	 * @param page
	 * @return
	 * @throws Exception
	 */
	
	public List<PageData> findAllProject(Page page)throws Exception{
		return (List<PageData>) dao.findForList("UnfundrojectMapper.findAllProject", page);
	}
	/**
	 *查找项目
	 * <p>Title: searchProject</p>
	 * <p>Description: </p>
	 * @param page
	 * @return
	 * @throws Exception
	 */
	
	public List<PageData> searchProject(Page page)throws Exception{
		return (List<PageData>) dao.findForList("UnfundrojectMapper.searchProject", page);
	}
	/**
	 * 搜索用户
	 * <p>Title: searchUser</p>
	 * <p>Description: </p>
	 * @param page
	 * @return
	 * @throws Exception
	 */
	public List<PageData> searchUser(Page page)throws Exception{
		return (List<PageData>) dao.findForList("UsersMapper.searchUser", page);
	}
	
	/**查找用户奖励记录第一步
	 * 查看用户相关的卡 
	 * <p>Title: listPdPageUser</p>
	 * <p>Description: </p>
	 * @param page
	 * @return
	 * @throws Exception
	 */
	public List<Account> listAllUserAccount(Page page)throws Exception{
		return (List<Account>) dao.findForList("AccountMapper.findUsersAccount", page);
	}
	/**查找用户奖励记录第二步
	 * 查看用户相关的记录 
	 * <p>Title: listPdPageUser</p>
	 * <p>Description: </p>
	 * @param page
	 * @return
	 * @throws Exception
	 */
	public List<PageData> listAllUserRecord(PageData page)throws Exception{
		return (List<PageData>) dao.findForList("RecordMapper.findUsersRecord", page);
	}
	
	
	public List<PageData> findRecordById(PageData page)throws Exception{
		return (List<PageData>) dao.findForList("RecordMapper.findRecordById", page);
	}
	public List<PageData> findRecordByIdAndUid(PageData page)throws Exception{
		return (List<PageData>) dao.findForList("RecordMapper.findRecordByIdAndUid", page);
	}
	
	/**
	 * 获取项目通过项目ID
	 * <p>Title: findProjectById</p>
	 * <p>Description: </p>
	 * @param page
	 * @return
	 * @throws Exception
	 */
	public List<PageData> findProjectById(PageData page)throws Exception{
		return (List<PageData>) dao.findForList("UnfundrojectMapper.findProjectById", page);
	}
	
	public List<PageData> findAccountByUid(PageData page)throws Exception{
		return (List<PageData>) dao.findForList("AccountMapper.findAccountByUid", page);
	}
	
	/***
	 * 获取项目通过UserId
	 * <p>Title: findUserProjectListByUserId</p>
	 * <p>Description: </p>
	 * @param page
	 * @return
	 * @throws Exception
	 */
	public List<PageData> findUserProjectListByUserId(PageData page)throws Exception{
		return (List<PageData>) dao.findForList("UnfundrojectMapper.findUserProjectListByUserId", page);
	}
	
	
	/*
	* 修改项目进度
	*/
	public void editProject(PageData pd)throws Exception{
		dao.update("UnfundrojectMapper.editProject", pd);
	}
	
	/*
	* 修改奖励记录
	*/
	public void editRecord(PageData pd)throws Exception{
		dao.update("RecordMapper.editRecord", pd);
	}
	/*
	* 修改奖励记录
	*/
	public void addRecord(PageData pd)throws Exception{
		dao.update("RecordMapper.addRecord", pd);
	}
	/*
	 * 根据项目得到用户Id
	 */
	public List<PageData>  getUserIdByProId(PageData pd)throws Exception{
		return (List<PageData>)dao.findForList("UnfundrojectMapper.getUserIdByProId", pd);
	}
	
}

